@abraca/cli 1.8.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1285,7 +1285,14 @@ function elementTextContent(el) {
1285
1285
  for (let i = 0; i < el.length; i++) {
1286
1286
  const child = el.get(i);
1287
1287
  if (child instanceof yjs.XmlText) parts.push(xmlTextToMarkdown(child));
1288
- else if (child instanceof yjs.XmlElement) parts.push(elementTextContent(child));
1288
+ else if (child instanceof yjs.XmlElement) {
1289
+ if (child.nodeName === "docLink") {
1290
+ const docId = child.getAttribute("docId");
1291
+ if (docId) parts.push(`[[${docId}]]`);
1292
+ continue;
1293
+ }
1294
+ parts.push(elementTextContent(child));
1295
+ }
1289
1296
  }
1290
1297
  return parts.join("");
1291
1298
  }
@@ -1314,7 +1321,9 @@ function serializeElement(el, indent = "") {
1314
1321
  case "table": return serializeTable(el);
1315
1322
  case "docEmbed": {
1316
1323
  const docId = el.getAttribute("docId");
1317
- return docId ? `![[${docId}]]` : "";
1324
+ if (!docId) return "";
1325
+ const seamlessAttr = el.getAttribute("seamless");
1326
+ return seamlessAttr === true || seamlessAttr === "true" ? `![[${docId}]]{seamless}` : `![[${docId}]]`;
1318
1327
  }
1319
1328
  case "svgEmbed": {
1320
1329
  const svg = el.getAttribute("svg") || "";
@@ -1628,14 +1637,12 @@ function parseInline(text) {
1628
1637
  text: kbdProps["value"] || "",
1629
1638
  attrs: { kbd: { value: kbdProps["value"] || "" } }
1630
1639
  });
1631
- } else if (match[5] !== void 0) {
1632
- const docId = match[5];
1633
- const displayText = match[6] ?? docId;
1634
- tokens.push({
1635
- text: displayText,
1636
- attrs: { link: { href: `/doc/${docId}` } }
1637
- });
1638
- } else if (match[7] !== void 0) tokens.push({
1640
+ } else if (match[5] !== void 0) tokens.push({
1641
+ text: "",
1642
+ node: "docLink",
1643
+ nodeAttrs: { docId: match[5] }
1644
+ });
1645
+ else if (match[7] !== void 0) tokens.push({
1639
1646
  text: match[7],
1640
1647
  attrs: { strike: true }
1641
1648
  });
@@ -1662,7 +1669,7 @@ function parseInline(text) {
1662
1669
  lastIndex = match.index + match[0].length;
1663
1670
  }
1664
1671
  if (lastIndex < stripped.length) tokens.push({ text: stripped.slice(lastIndex) });
1665
- return tokens.filter((t) => t.text.length > 0);
1672
+ return tokens.filter((t) => t.node || t.text.length > 0);
1666
1673
  }
1667
1674
  function parseTableRow(line) {
1668
1675
  const parts = line.split("|");
@@ -1790,11 +1797,14 @@ function parseBlocks(markdown) {
1790
1797
  i++;
1791
1798
  continue;
1792
1799
  }
1793
- const docEmbedMatch = line.match(/^!\[\[([^\]|]+?)(?:\|[^\]]*?)?\]\]\s*$/);
1800
+ const docEmbedMatch = line.match(/^!\[\[([^\]|]+?)(?:\|[^\]]*?)?\]\](\{[^}]*\})?\s*$/);
1794
1801
  if (docEmbedMatch) {
1802
+ const props = parseMdcProps(docEmbedMatch[2]);
1803
+ const seamless = "seamless" in props || props["seamless"] === "true" || /\{[^}]*\bseamless\b[^}]*\}/.test(docEmbedMatch[2] ?? "");
1795
1804
  blocks.push({
1796
1805
  type: "docEmbed",
1797
- docId: docEmbedMatch[1]
1806
+ docId: docEmbedMatch[1],
1807
+ seamless: seamless || void 0
1798
1808
  });
1799
1809
  i++;
1800
1810
  continue;
@@ -2072,13 +2082,22 @@ function parseBlocks(markdown) {
2072
2082
  return blocks;
2073
2083
  }
2074
2084
  function fillTextInto(el, tokens) {
2075
- const filtered = tokens.filter((t) => t.text.length > 0);
2085
+ const filtered = tokens.filter((t) => t.node || t.text.length > 0);
2076
2086
  if (!filtered.length) return;
2077
- const xtNodes = filtered.map(() => new yjs.XmlText());
2078
- el.insert(0, xtNodes);
2087
+ const children = filtered.map((tok) => {
2088
+ if (tok.node) {
2089
+ const xe = new yjs.XmlElement(tok.node);
2090
+ if (tok.nodeAttrs) for (const [k, v] of Object.entries(tok.nodeAttrs)) xe.setAttribute(k, v);
2091
+ return xe;
2092
+ }
2093
+ return new yjs.XmlText();
2094
+ });
2095
+ el.insert(0, children);
2079
2096
  filtered.forEach((tok, i) => {
2080
- if (tok.attrs) xtNodes[i].insert(0, tok.text, tok.attrs);
2081
- else xtNodes[i].insert(0, tok.text);
2097
+ if (tok.node) return;
2098
+ const xt = children[i];
2099
+ if (tok.attrs) xt.insert(0, tok.text, tok.attrs);
2100
+ else xt.insert(0, tok.text);
2082
2101
  });
2083
2102
  }
2084
2103
  function blockElName(b) {
@@ -2325,6 +2344,7 @@ function fillBlock(el, block) {
2325
2344
  break;
2326
2345
  case "docEmbed":
2327
2346
  el.setAttribute("docId", block.docId);
2347
+ if (block.seamless) el.setAttribute("seamless", "true");
2328
2348
  break;
2329
2349
  case "svgEmbed":
2330
2350
  el.setAttribute("svg", block.svg);